package com.demo.webflux.redis;

import java.io.Serializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import reactor.core.publisher.Mono;

@RestController
@RequestMapping("/article")
public class ArticleController {

	@Autowired
	private ArticleService articleService;

	@PostMapping("")
	public Mono<Boolean> saveArticle(@RequestBody final Article article){
		return articleService.saveArticle(article);
	}

	@GetMapping("/{id}")
	public Mono<Serializable> findOne(@PathVariable("id") final String id){
		return articleService.findArticleById(id);
	}

}